Skip to content

Fix: reuse each web chart's lazy component so remounts skip the spinner - #105283

Merged
luacmartins merged 3 commits into
Expensify:mainfrom
software-mansion-labs:fix/charts/spinner-flash-on-remount
Nov 10, 2026
Merged

luacmartins merged 3 commits into
Expensify:mainfrom
software-mansion-labs:fix/charts/spinner-flash-on-remount

Conversation

@sharabai

@sharabai sharabai commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

WithSkiaWeb creates a new React.lazy on every mount, and a new lazy suspends on its first render even when the chart's code and CanvasKit are already loaded. Production React commits the Suspense fallback for that render, so ChartReveal held its spinner over every chart remount. Concierge chart replies have no ChartReveal, so each time one opened, its bare fallback box showed for about 300 ms, the least time production React keeps a committed fallback on screen. Dev React replays the resolved lazy first, so a dev build never shows it. SkiaWebChart now calls LoadSkiaWeb itself and keeps one lazy per chart loader, so a remount renders without suspending.

getLazyChart drops a lazy whose load failed. A top-level lazy would keep that failure for the session and break the next-mount retry that the load-skia-web-fail-closed patch from #102138 relies on. Native uses the index.native.tsx entry points and is unchanged.

Fixed Issues

$ #105285
PROPOSAL: N/A

Follow-up to #103210

Tests

Preconditions:

  • Account A: an account with a few months of expenses.
  • All tests run on this PR's ad hoc web build (the pr-testing.expensify.com link in the test build comment), in Chrome on desktop.
  • For test 2, keep Chrome DevTools open.
  • For test 3, Account A's Concierge chat has a reply with a chart. To get one, send Concierge "expenses broken down by category" and wait for its reply, which takes about a minute.

Tests 1 and 3 exercise the fix. Test 2 is regression coverage for the retry after a failed load.

1. Switching between chart views that already loaded shows no spinner (Account A, web)

  1. Sign in as Account A and open Spend. If a chart shows, go to Display > View, pick Table, tap Apply and reload the page.
  2. In Display, check that Group by reads Month. If it does not, open Group by, pick Month and tap Apply. Then in Display > View, pick Line and tap Apply. Verify that a spinner shows and the line chart then fades in.
  3. In Display > View, pick Bar and tap Apply. Verify that the bar chart appears. A spinner can show the first time.
  4. In Display > View, pick Line and tap Apply. Verify that the line chart replaces the bar chart with no spinner showing in between.
  5. In Display > View, pick Bar and tap Apply. Verify that the bar chart replaces the line chart with no spinner showing in between.
Confirm the flash on main
  1. On https://staging.new.expensify.com, repeat steps 1 to 5.
  2. Verify that the spinner flickers over the chart card at steps 4 and 5.

2. A chart that failed to load loads on its next mount (Account A, web)

  1. In Display > View, pick Line and tap Apply, then reload the page.
  2. In DevTools, open the Request conditions panel. Click + (Add network request throttling or blocking pattern), type the page's origin followed by /canvaskit-0.41.0.wasm, press Enter, then reload the page.
  3. Verify that the chart card shows "Unable to display chart" and "The chart could not be loaded. Please refresh the page and try again."
  4. In Request conditions, untick the checkbox next to the canvaskit-0.41.0.wasm pattern.
  5. In Display > View, pick Bar and tap Apply. Verify that the bar chart appears.
  6. In Display > View, pick Line and tap Apply. Verify that the line chart appears without reloading the page.

3. Reopening a Concierge reply with a chart shows no loading box (Account A, web)

  1. Go to the build's /concierge page. If the chat opens on "Ask me anything!", click View chat history under it. Under the message that got the chart reply, click 1 Reply. Verify that the chart appears. A box with a spinner can show the first time.
  2. Press the browser's Back button. Verify that the Concierge chat shows.
  3. Click the same 1 Reply again. Verify that the chart shows with no box with a spinner before it.
Confirm the flash on main
  1. On https://staging.new.expensify.com, repeat steps 1 to 3.
  2. Verify that at step 3 a narrow box with a spinner shows where the chart goes, and the chart then replaces it.
  • Verify that no errors appear in the JS console

Offline tests

N/A: the change only decides whether a chart that already loaded suspends again when it remounts, and network state adds no path to that.

QA Steps

Same as tests, on staging, without the "Confirm the flash on main" blocks.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native

N/A: native charts render through the index.native.tsx entry points, which this change does not touch.

Android: mWeb Chrome
iOS: Native

N/A: native charts render through the index.native.tsx entry points, which this change does not touch.

iOS: mWeb Safari
MacOS: Chrome / Safari
pr-105283-test-3-reopening-concierge-chart-reply-shows-no-loading-box-on-staging-main.mp4
pr-105283-test-3-reopening-concierge-chart-reply-shows-no-loading-box.mp4
pr-105283-test-2-failed-chart-loads-on-next-mount.mp4
pr-105283-test-1-switching-between-chart-views-shows-no-spinner-on-staging-main.mp4
pr-105283-test-1-switching-between-chart-views-shows-no-spinner.mp4

@dylanexpensify

Copy link
Copy Markdown
Contributor

@sharabai any update here?

@mhawryluk

Copy link
Copy Markdown
Member

Sergei is sick, so no update here :(

@sharabai

sharabai commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@sharabai

sharabai commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@sharabai

sharabai commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot find regressions

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T14:56:38.777841Z ddf8dc7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

Web verification was blocked: the account has no expenses, Concierge returned no chart, and the production spinner fix remains unverified. Code review found no actionable regressions; all 35 tests across five focused Jest suites passed.

Concierge reply reports no expenses instead of a chart

Step Status
1.1 — Open Spend, select Table, reloadSpend showed “No expenses yet”; no Table selector was available. Reload was unavailable under session restrictions.
Spend shows No expenses yet
⚠️
1.2 — Month grouping and initial Line loadingBlocked by missing expense data.
⚠️
1.3 — Initial Bar renderingBlocked by missing expense data.
⚠️
1.4 — Switch back to Line without spinnerNo chart available to verify remounting.
⚠️
1.5 — Switch back to Bar without spinnerNo chart available to verify remounting.
⚠️
2.1 — Select Line and reloadMissing chart fixture; reload unavailable under session restrictions.
⚠️
2.2 — Block CanvasKit and reloadNetwork interception was unsupported by available browser controls.
⚠️
2.3 — Verify load-failure messagesCould not induce the WASM failure; messages remain unverified.
⚠️
2.4 — Remove CanvasKit blockNot tested; no block was installed.
⚠️
2.5 — Verify Bar recoversFailure/recovery prerequisites unavailable.
⚠️
2.6 — Verify Line recovers without reloadFailure/recovery prerequisites unavailable.
⚠️
3.1 — Open Concierge chart replyOpened the reply, but Concierge reported no expenses rather than displaying a chart.
Concierge reply reports no expenses instead of a chart
⚠️
3.2 — Back returns to ConciergeChart prerequisite absent; browser Back unavailable through permitted controls.
⚠️
3.3 — Reopen reply without loading boxReply contained no chart, so remount behavior remains unverified.
⚠️
Console — No related JavaScript errorsConsole inspection unavailable; absence of errors remains unverified.
⚠️
Optional staging baselineNot tested; no separate staging session available.
⚠️

view run

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

Browser verification was blocked by missing expenses and chart replies, so production spinner behavior remains unverified. No actionable regressions were found in the lazy-cache/retry logic or reveal lifecycle: 97 existing tests passed, plus 11 temporary adversarial tests covering concurrent loading, failures, remounts, and prop changes.

Concierge history showing only its welcome message

Step Status
Chart loadingSpend and Insights showed empty states requiring expenses; no chart was available.
Insights empty state requiring expenses
⚠️
Switch previously loaded Line/Bar/Pie chartsNo loaded chart or chart-type controls were available.
No chart fixture available in Insights
⚠️
Reopen Concierge chart repliesChat history contained only the welcome message, with no chart reply to reopen. Browser console errors were not inspected.
Concierge history showing only its welcome message
⚠️

view run

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 0a7396d458

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/Charts/SkiaWebChart/index.tsx 100.00% <100.00%> (ø)
... and 46 files with indirect coverage changes

@sharabai
sharabai marked this pull request as ready for review November 9, 2026 14:40
@sharabai
sharabai requested review from a team as code owners November 9, 2026 14:40
@melvin-bot
melvin-bot Bot requested review from daledah and removed request for a team November 9, 2026 14:40
@melvin-bot

melvin-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

@daledah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team November 9, 2026 14:40
@luacmartins
luacmartins self-requested a review November 9, 2026 21:31

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No product review required

@daledah

daledah commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

MacOS: Chrome / Safari
web-resize.mp4

@daledah daledah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code changes LGTM

@luacmartins
luacmartins merged commit 9cd61ff into Expensify:main Nov 10, 2026
43 of 47 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR only fixes loading-spinner flicker when reopening previously loaded charts; it adds no feature or workflow and makes no existing article sentence incorrect.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed — this PR only fixes spinner flicker when reopening previously loaded web charts, without adding new user-facing functionality or sensitive content.


view run

@IuliiaHerets

IuliiaHerets commented Nov 11, 2026 •

Copy link
Copy Markdown

Hi @sharabai. QA team couldn’t test Test 2, step 2.

image

Could you either explain exactly how to do it, or verify this scenario internally?
Tests 1 and 3 pass. Thanks!

cc @JmillsExpensify @dylanexpensify @daledah

@sharabai

Copy link
Copy Markdown
Contributor Author

Thanks @IuliiaHerets! Here's test 2 recorded on the ad hoc build with DevTools open:

pr-105283-test-2-failed-chart-loads-on-next-mount-devtools.mp4

Request conditions is in DevTools' ⋮ menu (top right of DevTools) under More tools, and it opens in the bottom drawer. Click + in its toolbar, type https://105283.pr-testing.expensify.com/canvaskit-0.41.0.wasm, press Enter, then reload the page. Older Chrome versions call the same panel Network request blocking.

@IuliiaHerets

Copy link
Copy Markdown

@sharabai The QA team tested this in staging, not in the ad hoc build.
So we should use the following URL: https://staging.new.expensify.com/canvaskit-0.41.0.wasm, correct?

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants